define('/static/js/view/jobDetail', function ( require, exports, module ) {
    
    var tpl = require('template/jobDetail')
    , _waiting = function ( attrId ) {
        $('div[data-jid='+attrId+']').addClass('waitBg');
    }
    , _removeWaiting = function ( attrId ) {
        setTimeout(function () {
            $('div[data-jid='+attrId+']').removeClass('waitBg');
        }, 1000);
    };

    $('#zhaopinItems').on('click', '.items > div', function () {
        location.hash = '#/job/'+$(this).data('jid');
    });
    
    return Backbone.View.extend({
    
        id: 'detail',
		
		className: 'animated bounceInRight',

        parent: $('#wrapper'),
        
        template: tpl,
        
        events: {
            'click .close': 'closeDetail'
        },

        initialize: function () {
            this.render();
        },

        render: function () {
            this.parent.append( this.$el.html( ejs.render( this.template, this.model ) ) );
        },

        closeDetail: function () {
			var self = this;
            _removeWaiting(self.model.data.jid);
            this.$el.addClass('bounceOutRight').one('webkitAnimationEnd', function () {
				self.remove();
			});
        },
		
		destoryPage: function () {
			this.remove();
		}

    }, {
        waiting: _waiting,
        removeWaiting: _removeWaiting
    });

});
